from django.db import models
from utils.BaseModel import BaseModel
# Create your models here.
class Nav(BaseModel):
    name = models.CharField(max_length=20, verbose_name='导航名称', unique=True)
    url = models.CharField(max_length=200, verbose_name='导航链接', null=True, blank=True)
    postion = models.IntegerField(default=0, verbose_name='导航位置')
    ishttp = models.BooleanField(verbose_name='是否是http链接', default=False)
    class Meta:
        db_table = 'fgnav'
        verbose_name = '导航'
class Banner(BaseModel):
    title=models.CharField(max_length=20,verbose_name="标题")
    img=models.CharField(max_length=200,verbose_name="图片",default="")
    islink=models.BooleanField(verbose_name="是否是链接",default=False)
    url=models.CharField(max_length=200,verbose_name="链接",null=True,blank=True)
    class Meta:
        db_table="fgbanner"
        verbose_name="轮播图"
class Category(BaseModel):
    name = models.CharField(max_length=100, verbose_name="分类名称")
    parent = models.ForeignKey('self', null=True, blank=True, verbose_name="父级分类", on_delete=models.CASCADE,related_name='children')
    intro = models.TextField(verbose_name="分类介绍")
    ishome = models.BooleanField(default=False, verbose_name="是否首页展示")

    class Meta:
        db_table = "category"
        verbose_name = "分类表"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name
